package cn.enilu.flash.warpper;

import cn.enilu.flash.enums.body.ParkOwnerFlag;
import cn.enilu.flash.enums.body.ParkType;
import cn.enilu.flash.enums.body.QuoteType;
import cn.enilu.flash.enums.body.QuoteUnit;
import cn.enilu.flash.service.system.impl.ConstantFactory;
import cn.enilu.flash.utils.StringUtils;

import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2019/11/05 9:40)
 * @Version v1.0
 * @Modify
 **/
public class ParkInfoWarpper extends BaseControllerWarpper {
    public ParkInfoWarpper(List<Map<String, Object>> list) {
        super(list);
    }

    public ParkInfoWarpper(Map<String, Object> map) {
        super(map);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
        map.put("ownerFlagName", ParkOwnerFlag.valueOfCode((Integer) map.get("ownerFlag")));
        map.put("parkingTypeName", ParkType.valueOfCode((Integer) map.get("parkingType")));
        if(StringUtils.isNotNullOrEmpty(map.get("communityId"))) {
            map.put("communityName", ConstantFactory.me().getCommunityNameById((Long) map.get("communityId")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("buildingId"))) {
            map.put("buildingName", ConstantFactory.me().getBuildingNameById((Long) map.get("buildingId")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("roomId"))) {
            map.put("roomName", ConstantFactory.me().getRoomNameById((Long) map.get("roomId")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("ownerFlag"))
                && (Integer)map.get("ownerFlag") != ParkOwnerFlag.BLANK.getCode()){
            map.put("custName", ConstantFactory.me().getCustNameByParkingId((Long)map.get("id")));
        }else{
            map.put("custName", "--");
        }
    }
}
